import random
import math

class Example(object):
    
    def __init__(self, attrs, label):
        '''
        Constructor
        '''
        self.label = label
        self.attrs = []
        for attr in attrs:
            self.attrs.append(attr)
        
    @staticmethod
    def create_random(bounds, attr_num):
        attr = []
        for i in range(0, attr_num):
            attr.append(random.uniform(bounds[0], bounds[1]))
        label = ""
        return Example(attr, label)
    
    def euclidean(self, irys):
        dist = 0
        for (attr1, attr2) in zip(self.attrs, irys.attrs):
            dist = dist + math.pow(attr1 - attr2, 2)
        return math.sqrt(dist)
        
    def __repr__(self, *args, **kwargs):
        return "class:\n" + self.label + "\nattributes:\n" + str(self.attrs) + "\n" 

    
